package hanqi.busline.Controller;

import hanqi.busline.Line;
import hanqi.busline.Service.BusLineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/bus")
public class Controller {
    @Autowired
    private BusLineService busLineService;
    @GetMapping("/getAll")
    public List<Line>  getallBusLine() {
        return busLineService.getallBusLine();
    }
    @GetMapping("getBusLine/{id}")
    public Line getBusLine(@PathVariable Integer id) {
        return busLineService.getBusLineById(id);
    }
    @PostMapping("/addBusline")
    public String addBusline(@RequestBody Line line) {
        busLineService.insertBusLine(line);
        return "插进来哩，叔叔的数据全都插进来哩，嘻嘻~~";
    }
    @PutMapping("/updateBusline")
    public String updateBusline(@RequestBody Line line) {

        busLineService.updateBusLine(line);
        return "真拿你没办法就让你稍微改一下好了Ciallo～(∠・ω< )⌒★";
    }
    @DeleteMapping("/deleteBusline/{id}")
    public String deleteBook(@PathVariable Integer id) {
        busLineService.deleteBusLineByid(id);
        return "咕，被删掉哩T_T";
    }
    @GetMapping("getBusLinebyname/{station}")
    public List<Line> getBusLine(@PathVariable String station) {

        return busLineService.getBusLineByName(station);
    }


}
